package com.easemob.helpdesk;

import android.util.Log;
import android.widget.Toast;

import com.easemob.helpdesk.utils.HDNotifier;
import com.housekeeperapp.MainApplication;
import com.hyphenate.kefusdk.HDEventListener;
import com.hyphenate.kefusdk.HDNotifierEvent;
//import com.hyphenate.kefusdk.bean.HDSession;
import com.hyphenate.kefusdk.chat.HDClient;
import com.hyphenate.kefusdk.entity.HDMessage;

/**
 * Created by lyuzhao on 2016/1/11.
 */
public class IMHelper {

    private static final String TAG = IMHelper.class.getSimpleName();
    /**
     * global IM Helper instance
     */
    private static IMHelper instance = null;
    /**
     * HDEventListener
     */
    private HDEventListener eventListener;

    private IMHelper(){
    }

    public synchronized static IMHelper getInstance(){
        if(instance == null){
            instance = new IMHelper();
        }
        return instance;
    }



    public void setGlobalListener(){

        //register message event listener
//        registerEventListener();

    }

//    protected void registerEventListener() {
//        if (eventListener == null){
//            eventListener = new HDEventListener() {
//                @Override
//                public void onEvent(HDNotifierEvent event) {
//
//                    Log.d(TAG, "registerEventListener===onEvent: "+Thread.currentThread());
//                    final Object data = event.getData();
//
//                    switch (event.getEvent()){
//                        case EventNewMessage:
//                            if(data instanceof HDMessage){
//                                HDMessage message = (HDMessage) data;
//
//                                if(!message.isAgentChat()){
//                                    HDNotifier.getInstance().notifiChatMsg(message);
//                                }
//                            }
//
//                            break;
//
//                        case EventNewSession:
//                            if (MainApplication.getInstance() == null || MainApplication.getInstance().isNoActivity()){
//                                HDNotifier.getInstance().notifiChatMsg(null);
//                            }
//                            break;
//
//                        case EventVisitorWaitListChange:
//                            if (MainApplication.getInstance() == null || MainApplication.getInstance().isNoActivity()){
//                                HDNotifier.getInstance().notifiChatMsg(null);
//                            }
//                            break;
//                        default:break;
//                    }
//
//                }
//            };
//            HDClient.getInstance().chatManager().addEventListener(eventListener, new HDNotifierEvent.Event[]{HDNotifierEvent.Event.EventNewMessage, HDNotifierEvent.Event.EventNewSession, HDNotifierEvent.Event.EventVisitorWaitListChange});
//        }
//
//    }


}
